@extends('manage.layout')

@section('content')
    <section class="content-header">
        <h1>
            分享列表
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="#">Share</a></li>
            <li class="active">Share List</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title">内容</h3>
                        <span style="float:right;color: #bbb">共{{$count}}条结果</span>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table class="table table-bordered table-hover">
                            <thead>
                            <tr>
                                <th style="min-width: 50px">ID</th>
                                <th style="min-width: 50px">权重</th>
                                <th style="min-width: 150px">
                                    更新时间&nbsp;&nbsp;
                                    <a href="/share?orderBy=1"><i class="fa fa-arrow-up"></i></a>&nbsp;&nbsp;
                                    <a href="/share?orderBy=2"><i class="fa fa-arrow-down"></i></a>
                                </th>
                                <th style="min-width: 150px">标题</th>
                                <th style="min-width: 150px">分类</th>
                                {{--<th>内容</th>--}}
                                <th>分享人</th>
                                {{--<th style="min-width: 50px">附件</th>--}}
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($share as $s)
                                <tr>
                                    <td>{{ $s['id'] }}</td>
                                    <td>{{ $s['rank'] }}</td>
                                    <td>{{ $s['update_time'] }}</td>
                                    <td>{{ $s['title'] }}</td>
                                    <td>{{ App\Model\ShareCategory::find($s['category'])['name'] }}</td>
                                    {{--<td>{{ $s['content'] }}</td>--}}
                                    <td>{{ $s['dd_id'] }}</td>
                                    {{--<td><a href="http://vipyipoint.oss-cn-beijing.aliyuncs.com/{{ $s['attachment'] }}">下载</a></td>--}}
                                    <td>
                                        @if($s['status'] == 1)<label>启用</label>
                                        @else<label>禁用</label>
                                        @endif
                                    </td>
                                    <td>
                                        <a class="btn btn-info btn-xs"  href="{{ url('share/shareDetails/'.$s['id']) }}">详情预览<a>
                                            {{--<a class="btn btn-danger btn-xs" href="javascript:delCate({{ $c['id'] }})">删除<a>--}}
                                        @if($s['status'] == 1)
                                            <a class="btn btn-warning btn-xs" href="javascript:shareStatus('{{ $s['id'] }}',0)">禁用<a>
                                        @elseif($s['status'] == 0)
                                            <a class="btn btn-success btn-xs" href="javascript:shareStatus('{{ $s['id'] }}',1)">启用<a>
                                        @endif
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                    <div style="text-align: center;">
                        {{ $share->appends(['count'=>$count,'orderBy'=>$orderBy])->links() }}
                    </div>
                    <!-- /.box-body -->
                </div>
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </section>
@stop
@section('script')
    <script>

        //禁用,启用
        function shareStatus(id,status) {
            console.log(id);
            console.log(status);
            $.ajax({
                url: '/share/shareStatus',
                type: "GET",
                data: {id:id,status:status},
                dataType: "json",
                success: function(res) {
                    console.log(res);
                    if(res.code == 100) {
                        window.location.href=window.location.href;
                        layer.msg(res.msg, {time:1500, icon:6})
                    }
                    else {
                        layer.msg(res.msg, {time:1500, icon:5});
                    }
                }
            });
        }
    </script>
@stop